﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MiniErp.Core.Filters;
using MiniErp.Entity.DataStreams.DTOs.Notice;
using MiniErp.Service.BusinessService.IService.Notice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MiniErp.Core.Controllers.Notice
{

    /// <summary>
    /// 公告系统控制器
    /// </summary>
    [Route("UserNotices")]
    public class UserNoticesController : ApiControllers
    {
        private readonly IUserInfoNoticesReplyService _userInfoNoticesReplyService;
        public UserNoticesController(IUserInfoNoticesReplyService userInfoNoticesReplyService)
        {
            _userInfoNoticesReplyService = userInfoNoticesReplyService;
        }


        /// <summary>
        /// 根据用户编号以及时间查询所有公告回复 //分页
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        /// <param name="starttime">开始时间</param>
        /// <param name="endtime">结束时间</param>
        [HttpGet]
        [Route("GetUserInfoNoticesReplyByUserIdAndTimeAsync")]
        public Task<List<UserInfoNoticesReplyDTO>> GetUserInfoNoticesReplyByUserIdAndTimeAsync(int uid, DateTime starttime, DateTime endtime, int page, int num)
        {
            return _userInfoNoticesReplyService.GetUserInfoNoticesReplyByUserIdAndTimeAsync(uid, starttime, endtime, page, num);
        }
        /// <summary>
        /// 根据公告编号查询所有公告回复 //分页
        /// </summary>
        /// <param name="noticesid">公告编号</param>
        /// <param name="page">页码</param>
        /// <param name="num">每页数据条数</param>
        [HttpGet]
        [Route("GetUserInfoNoticesReplyByNoticesIdAsync")]
        public Task<List<UserInfoNoticesReplyDTO>> GetUserInfoNoticesReplyByNoticesIdAsync(int noticesid, int page, int num)
        {
            return _userInfoNoticesReplyService.GetUserInfoNoticesReplyByNoticesIdAsync(noticesid, page, num);
        }

        /// <summary>
        /// 修改公告回复=> 用户回复
        /// </summary>
        /// <param name="NoticesDTO">修改公告回复DTO</param>
        [HttpPost]
        [Route("UpdateUserInfoNoticesReplyAsync")]
        public Task<bool> UpdateUserInfoNoticesReplyAsync(UpdateUserInfoNoticesReplyDTO NoticesDTO)
        {
            return _userInfoNoticesReplyService.UpdateUserInfoNoticesReplyAsync(NoticesDTO);
        }
    }
}
